<template>
  <div>
    <!-- <avue-group label="线下正常售卖">
      <avue-crud
        :data="offlineSellList"
        :option="offlineSellTbleOption"
      ></avue-crud>
    </avue-group> -->
    <avue-group label="转账/线下核销明细">
      <avue-crud
        :data="offlineTaketList"
        :option="offlineTaketTbleOption"
      ></avue-crud>
    </avue-group>
    <avue-group label="团购售卖">
      <avue-crud
        :data="groupSellList"
        :option="groupSellTableOption"
      ></avue-crud>
    </avue-group>
  </div>
</template>

<script>
import {
  getNeedConfirmData,
  confirm
} from "@/api/subwaystm/swstmarketingticket/swstmarketingticket";
import { checkPwd } from "@/api/admin/user";
import { dateFormat } from "@/util/date";
export default {
  name: "marketing-ticket",
  data() {
    return {
      marketingTicket: {},
      offlineTaketList: [],
      //offlineSellList: [],
      groupSellList: [],
      offlineTaketTbleOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: "车票名称",
            prop: "ticketName",
            type: "select",
            dicUrl: "/support/swpmticketcardtypeparam/dictAll/{{key}}",
            props: {
              label: "subName",
              value: "subEnName"
            }
          },
          {
            type: "input",
            label: "票价",
            prop: "ticketPrice"
          },
          {
            type: "input",
            label: "张数",
            prop: "ticketNum"
          },
          {
            type: "number",
            label: "售卖金额",
            prop: "sellAmount",
            precision: 2
          },
          {
            type: "input",
            label: "取票方式",
            prop: "takeTicketWay",
            dicUrl: "/admin/dict/type/take_ticket_type"
          },
          {
            type: "number",
            label: "回执单号",
            prop: "ticketWayNum",
            precision: 2,
	    hide: true
          },
          {
            type: "input",
            label: "日期",
            prop: "takeTicketTime"
          }
        ]
      },
      offlineSellTbleOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: "车票名称",
            prop: "ticketName",
            type: "select",
            dicUrl: "/support/swpmticketcardtypeparam/dictAll/{{key}}",
            props: {
              label: "subName",
              value: "subEnName"
            }
          },
          {
            type: "input",
            label: "票价",
            prop: "ticketPrice"
          },
          {
            type: "number",
            label: "现金售卖张数",
            prop: "cashSellNum"
          },
          {
            type: "number",
            label: "现金售卖金额",
            prop: "cashSellAmount",
            precision: 2
          },
          {
            type: "number",
            label: "支付宝售卖张数",
            prop: "alipaySellNum"
          },
          {
            type: "number",
            label: "支付宝售卖金额",
            prop: "alipaySellAmount",
            precision: 2
          },
          {
            type: "number",
            label: "微信售卖张数",
            prop: "wechatSellNum"
          },
          {
            type: "number",
            label: "微信售卖金额",
            prop: "wechatSellAmount",
            precision: 2
          },
          {
            type: "number",
            label: "合计张数",
            prop: "totalSellNum"
          },
          {
            type: "number",
            label: "合计金额",
            prop: "totalSellAmount",
            precision: 2
          },
          {
            type: "datetime",
            label: "日期",
            prop: "sellTime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss"
          }
        ]
      },
      groupSellTableOption: {
        border: true,
        header: false,
        align: "center",
        headerAlign: "center",
        menu: false,
        index: true,
        indexLabel: "序号",
        column: [
          {
            label: "车票名称",
            prop: "ticketName",
            type: "select",
            dicUrl: "/support/swpmticketcardtypeparam/dictAll/{{key}}",
            props: {
              label: "subName",
              value: "subEnName"
            }
          },
          {
            type: "input",
            label: "票价",
            prop: "ticketPrice"
          },
          {
            type: "input",
            label: "支付方式",
            prop: "payMethod",
            dicUrl: "/admin/dict/type/pay_type"
          },
          {
            type: "number",
            label: "售卖张数（张）",
            prop: "sellNum"
          },
          {
            type: "number",
            label: "售卖金额",
            prop: "sellAmount",
            precision: 2
          },
          {
            type: "number",
            label: "折扣率（%）",
            prop: "discountRate",
            precision: 2
          },
          {
            type: "number",
            label: "折扣后金额",
            prop: "discountAmount",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss"
          },
          {
            type: "input",
            label: "回执单号",
            prop: "ticketWayNum",
            cell: true
          },
          {
            type: "date",
            label: "售卖日期",
            prop: "sellTime",
            width: 150,
            cell: true,
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd"
          }
        ]
      },
      isSubmit: false
    };
  },
  computed: {},
  methods: {
    getData(searchForm) {
      getNeedConfirmData(searchForm).then(response => {
        var result = response.data.data || {};
        this.marketingTicket = result.marketingTicket || {};
        this.offlineTaketList = result.ticketOffineTakeTickets || [];
        //this.offlineSellList = result.ticketOffineSells || [];
        this.groupSellList = result.ticketGroupSells || [];
      });
    }
    // submit() {
    //   if (!this.searchForm.nsJobNo) {
    //     this.$message.info("请选择售票员");
    //     return;
    //   }
    //   this.isSubmit = true;
    //   this.$prompt("请输入售票员密码", "确认", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     inputType: "password",
    //     inputValidator: val => {
    //       if (!val) return "请输入密码";
    //     }
    //   })
    //     .then(({ value }) => {
    //       return checkPwd(this.searchForm.nsJobNo, value);
    //     })
    //     .then(response => {
    //       var result = response.data.data;
    //       if (result) {
    //         return;
    //       } else {
    //         this.$message.error("密码错误");
    //         return Promise.reject("密码错误");
    //       }
    //     })
    //     .then(() => {
    //       return confirm(this.marketingTicket.id);
    //     })
    //     .then(() => {
    //       this.getData();
    //       this.$message.success("确认成功");
    //       this.isSubmit = false;
    //     })
    //     .catch(error => {
    //       console.log(error);
    //       this.isSubmit = false;
    //     });
    // }
  }
};
</script>

<style lang="scss" scoped>
.bottom-menu {
  text-align: center;
}
</style>
